
package com.epam.androids.training.day10;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Db openHelper Creates/upgrades db
 * 
 * @author Natallia_Kukharchyk
 */
public class TeaOpenHelper extends SQLiteOpenHelper {
  private static final String DATABASE_NAME = "teadb";

  public static final String TEA_TABLE_NAME = "tea";

  public static final String TEA_NAME = "tea_name";

  public static final String TEA_SORT = "tea_sort";

  private static final int DATABASE_VERSION = 2;

  private static final String TEA_TABLE_CREATE = "CREATE TABLE " + TEA_TABLE_NAME + " (" + TEA_NAME + " TEXT, "
      + TEA_SORT + " TEXT);";

  TeaOpenHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);

  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    db.execSQL(TEA_TABLE_CREATE);

  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
    db.execSQL("DROP TABLE IF EXISTS " + TEA_TABLE_NAME);
    onCreate(db);
  }

}
